package com.evil.common.core.enums;

public interface BaseEnum {
    int getCode();
    String getMessage();

    BaseEnum SUCCESS = BaseEnum.build(0, "操作成功");
    BaseEnum ERROR = BaseEnum.build(-1, "网络异常，请稍后重试");
    BaseEnum RUN_ERROR = BaseEnum.build(-2, "系统异常，请稍后重试");
    BaseEnum ERROR_PARAMETER = BaseEnum.build(1001, "参数错误");
    BaseEnum ACCESS_DENIED = BaseEnum.build(1112, "拒绝访问");
    BaseEnum LIMIT_ERROR = BaseEnum.build(1114, "操作太频繁");

    static BaseEnum build(int code, String message) {
        return new BaseEnum() {
            @Override
            public int getCode() {
                return code;
            }

            @Override
            public String getMessage() {
                return message;
            }
        };
    }
}
